// 创建文件
var blob = function (options) {
    var buffer = new ArrayBuffer(options.size || 0);
    var arr = new Uint8Array(buffer);
    [].forEach.call(arr, function (char, i) {
        arr[i] = 0;
    });
    var opt = {};
    options.type && (opt.type = options.type);
    var blob = new Blob([buffer], options);
    return blob;
}
// 给文件分块
var fileSlice = function (file, start, end, callback) {
    var blob;
    if (file.slice) {
        blob = file.slice(start, end);
    } else if (file.mozSlice) {
        blob = file.mozSlice(start, end);
    } else if (file.webkitSlice) {
        blob = file.webkitSlice(start, end);
    }

    var reader = new FileReader();
    reader.onload = function (e) {
        callback(e.target.result);
    };
    reader.readAsArrayBuffer(blob);
};
// 清除上次测试结果
var clearResult = function () {
    let div = document.querySelector('#mocha')
    let mochaStats = document.querySelector('#mocha-stats');
    let mochaReport = document.querySelector('#mocha-report');
    if (mochaStats) {
        div.removeChild(mochaStats);
    }
    if (mochaReport) {
        div.removeChild(mochaReport);
    }
}
// 运行单个测试
var runTest = function (testName) {
    if (mocha._state !== 'init') {
        return;
    }
    clearResult();
    mocha.suite.suites = [];
    this[testName]();
    mocha.run();
}
// 运行全部测试
var runAllTest = function () {
    if (mocha._state !== 'init') {
        return;
    }
    clearResult();
    mocha.suite.suites = [];
    acl();
    copyPut();
    copyMultipart();
    multipart();
    uploadPut();
    uploadPost();
    uploadMultipart();
    uploadFile();
    mocha.run();
}